package com.wanxi.IO;

import java.io.*;

public class MyIo {
    public static void main(String[] args) throws Exception {
        String path = "";
        String fileName = "";
        File dir = new File(path);
        dir.mkdirs();
        File file = new File(dir, fileName);
        OutputStream outputStream = new FileOutputStream(file);
        outputStream.write(88);
        byte[] bytes = new byte[1111];
        outputStream.write(bytes);
        InputStream inputStream = new FileInputStream(file);
        inputStream.read();
//        文件里面不止一个字符
        int length = 0;
        while ((length = inputStream.read(bytes)) != -1) {
//            outputStream.write(length);
            outputStream.write(bytes, 0, length);
        }
//----------------------------------------------------------
        Writer writer = new FileWriter(file);
        writer.write(99);
        char[] bytesWriter = new char[1111];
        writer.write(bytesWriter);
        Reader reader = new FileReader(file);
        int read = 0;
        while ((read = reader.read()) != -1) {
            writer.write(read);
        }
        reader.read();
//        --------------------------

        BufferedReader bufferedReader=new BufferedReader(reader);
        bufferedReader.readLine();//直接读一行
        bufferedReader.read();
        BufferedWriter bufferedWriter=new BufferedWriter(writer);
        bufferedWriter.newLine();//换两行  \n
        bufferedWriter.write(99);

    }
}
